package cn.westv.scps.domain;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.hibernate.annotations.GenericGenerator;

/**
 * Created by Administrator on 2017/08/09.
 */
@Entity(name = "sys_massage_send_record")
// @Table(name = "sys_massage_send_record", schema = "scps", catalog = "")
public class SysMassageSendRecordEntity implements Serializable {
	private String recordId;
	private Timestamp sendTime;
	private String msgType;

	private Set<AreaSeverEntity> areaSevers;

	private SysMessageEntity sysMessageEntity;

	@Id
	@Column(name = "record_id", nullable = false, length = 32)
	@GeneratedValue(generator = "uuid")
	@GenericGenerator(name = "uuid", strategy = "uuid")
	public String getRecordId() {
		return recordId;
	}

	public void setRecordId(String recordId) {
		this.recordId = recordId;
	}

	@Basic
	@Column(name = "send_time", nullable = true)
	public Timestamp getSendTime() {
		return sendTime;
	}

	public void setSendTime(Timestamp sendTime) {
		this.sendTime = sendTime;
	}

	@Basic
	@Column(name = "msg_type", nullable = true, length = 32)
	public String getMsgType() {
		return msgType;
	}

	public void setMsgType(String msgType) {
		this.msgType = msgType;
	}

	@ManyToMany(cascade = CascadeType.REFRESH)
	@JoinTable(name = "sysMassageSendRecordEntitys", joinColumns = @JoinColumn(name = "recordId"), inverseJoinColumns = @JoinColumn(name = "serverId"))
	public Set<AreaSeverEntity> getAreaSevers() {
		return areaSevers;
	}

	public void setAreaSevers(Set<AreaSeverEntity> areaSevers) {
		this.areaSevers = areaSevers;
	}

	@OneToMany(cascade = CascadeType.REFRESH, mappedBy = "sysMassageSendRecordEntitys")
	@JsonIgnore
	public SysMessageEntity getSysMessageEntity() {
		return sysMessageEntity;
	}

	@JsonIgnore
	public void setSysMessageEntity(SysMessageEntity sysMessageEntity) {
		this.sysMessageEntity = sysMessageEntity;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o == null || getClass() != o.getClass())
			return false;

		SysMassageSendRecordEntity that = (SysMassageSendRecordEntity) o;

		if (recordId != null ? !recordId.equals(that.recordId) : that.recordId != null)
			return false;
		if (sendTime != null ? !sendTime.equals(that.sendTime) : that.sendTime != null)
			return false;
		if (msgType != null ? !msgType.equals(that.msgType) : that.msgType != null)
			return false;

		return true;
	}

	@Override
	public int hashCode() {
		int result = recordId != null ? recordId.hashCode() : 0;
		result = 31 * result + (sendTime != null ? sendTime.hashCode() : 0);
		result = 31 * result + (msgType != null ? msgType.hashCode() : 0);
		return result;
	}
}
